﻿package export.hero
{
    
    import base.BaseBullet;
    import base.BaseHero;
    import base.BaseMonster;
    import base.BaseObject;
    import base.BaseSummon;
    
    import com.dusk.util.ArrayUtil;
    import com.dusk.util.McUtil;
    import com.dusk.util.RandomUtil;
    import com.game.data.constant.AddEffectType;
    import com.game.data.constant.FrameRate;
    import com.game.data.constant.HitType;
    import com.game.data.vo.AddEffectVO;
    import com.game.data.vo.HitResultVO;
    import com.game.data.vo.SkillVO;
    import com.game.manager.AnimationManager;
    import com.game.manager.SoundManager;
    
    import export.bullet.FollowTargetBullet;
    
    import export.bullet.RegionBullet;
    
    import flash.geom.Rectangle;
    import flash.utils.Dictionary;
    
    public class Role1 extends BaseHero
    {
        
        public function Role1()
        {
            super();
            horizonSpeed = 6;
        }
        
        private var shadowArray:Array = [];
        
        override protected function initCollideArea():void
        {
            collideBox = new Rectangle(-30, -100, 60, 103);
            super.initCollideArea();
        }
        
        override protected function initBBDC():void
        {
            var showInfo:Object = {
                weapon: 1,
                cloth: 1,
                wing: 1
            };
            bbdc = AnimationManager.getAnimation("Role1Action", showInfo);
            bbdc.setOffset(-35, 0);
            bbdc.setAction("idle");
            bbdc.turnRight();
            bbdc.addCallBack(onEnterFrame, onActionOver);
            bodyContainer.addChild(bbdc);
        }
        
        override public function setAction(act:String):void
        {
            var snd:String = "";
            var monArray:Array;
            var monster:BaseMonster;
            var shadow:Role1Shadow;
            switch (act)
            {
                case "dead":
                    snd = "Role1_dead";
                    break;
                case "hurt":
                    if (curAction != "hurt")
                    {
                        snd = "Role1_beAttack";
                        if (RandomUtil.randBoolean(20)) createShadow();
                    }
                    break;
                case "skill1":
                    //升龙斩
                    snd = "Role1_skill1_1";
                    if (actionRecord.getLastSkillAction() == act)
                    {
                        monArray = getPassiveMonsters();
                        if (monArray.length)
                        {
                            monster = McUtil.getNearestObj(this, monArray) as BaseMonster;
                            x = monster.x - 30 * bbdc.getDirect();
                            y = monster.y - 30;
                            act = "skill1_2";
                            snd = "Role1_skill1_2";
                        }
                    }
                    break;
                case "skill2":
                    //烈焰闪
                    snd = "Role1_skill2";
                    velocity.x = 35 * bbdc.getDirect();
                    break;
                case "skill3":
                    //连斩
                    setStatic();
                    if (actionRecord.getLastSkillAction() == act)
                    {
                        monArray = getPassiveMonsters();
                        if (monArray.length)
                        {
                            monster = McUtil.getNearestObj(this, monArray) as BaseMonster;
                            monster.velocity.y = 0;
                            x = monster.x - 70 * bbdc.getDirect();
                            y = monster.y - 70;
                            act = "skill3_2";
                            velocity.x = 15 * bbdc.getDirect();
                        }
                    }
                    break;
                case "skill4":
                    //身外身
                    velocity.x = 7 * bbdc.getDirect();
                    break;
                case "skill7":
                    //定海神针
                    snd = "Role1_skill7";
                    monArray = getPassiveMonsters();
                    if (monArray.length > 0)
                    {
                        for each(shadow in shadowArray)
                        {
                            shadow.setHurtRatio(monArray.length);
                            shadow.setAction("skill7");
                        }
                    }
                    break;
                case "skill6":
                    //火魔斩
                    snd = "Role1_skill6_1";
                    monArray = getPassiveMonsters();
                    if (monArray.length > 0)
                    {
                        for each(shadow in shadowArray)
                        {
                            shadow.setHurtRatio(monArray.length);
                            shadow.setAction("skill6");
                        }
                    }
                    break;
                case "skill8":
                    //血魔咆哮
                    snd = "Role1_skill8_1";
                    break;
                case "skill9":
                    //火眼金睛
                    snd = "Role1_skill9";
                    setStatic();
                    var vo:HitResultVO = new HitResultVO();
                    vo.hurt = 0.25 * getHp();
                    vo.hitType = HitType.MAGIC;
                    loseHp(vo);
                    curAddEffect.addEffects([{
                        type: AddEffectType.ROLE1_SKILL_HYJJ,
                        frame: FrameRate.ANIMATE_FRAME_RATE * 10,
                        value: player.getStudiedSkillBySkillId("hyjj").getSkillHurt()
                    }]);
            }
            if (snd)
            {
                SoundManager.playSound(snd);
            }
            super.setAction(act);
        }
        
        override protected function onEnterFrame(action:String, frameCount:int):void
        {
            var b:BaseBullet;
            switch (action)
            {
                case "attack1":
                    if (frameCount == 1)
                    {
                        b = new RegionBullet();
                        b.setCollideArea(0, -100, 100 * bbdc.getDirect(), 100);
                        b.setDestroyInCount(bbdc.frameLeft);
                        b.setOwner(this);
                        b.setAction("Role1Attack1");
                        b.setDirect(bbdc.getDirect());
                        b.setHurt(getActionHurt("attack1"));
                        b.hitVO.addEffect = [{
                            type: AddEffectType.ROLE1_PASSIVE_FIRE,
                            frame: FrameRate.ANIMATE_FRAME_RATE * 5,
                            value: 1
                        }];
                    }
                    break;
                case "attack2":
                    if (frameCount == 1)
                    {
                        b = new RegionBullet();
                        b.setCollideArea(0, -100, 150 * bbdc.getDirect(), 100);
                        b.setDestroyInCount(bbdc.frameLeft);
                        b.setOwner(this);
                        b.setAction("Role1Attack2");
                        b.setDirect(bbdc.getDirect());
                        b.setHurt(getActionHurt("attack2"));
                        b.hitVO.addEffect = [{
                            type: AddEffectType.ROLE1_PASSIVE_FIRE,
                            frame: FrameRate.ANIMATE_FRAME_RATE * 5,
                            value: 1
                        }];
                    }
                    break;
                case "attack3":
                    if (frameCount == 2)
                    {
                        b = new RegionBullet();
                        b.setCollideArea(-155, -100, 310 * bbdc.getDirect(), 100);
                        b.setDestroyInCount(8);
                        b.setOwner(this);
                        b.setAction("Role1Attack3");
                        b.setDirect(bbdc.getDirect());
                        b.setHurt(getActionHurt("attack3"));
                        b.hitVO.addEffect = [{
                            type: AddEffectType.ROLE1_PASSIVE_FIRE,
                            frame: FrameRate.ANIMATE_FRAME_RATE * 5,
                            value: 1
                        }];
                    }
                    break;
                case "attack4":
                    if (frameCount == 2)
                    {
                        moveTo(120 * bbdc.getDirect(), 0);
                        setSteelBody(8);
                    }
                    if (frameCount == 4)
                    {
                        b = new RegionBullet();
                        b.setCollideArea(33, -185, 210 * bbdc.getDirect(), 177);
                        b.setDestroyInCount(6);
                        b.setOwner(this);
                        b.setAction("Role1Attack4_1");
                        b.setDirect(bbdc.getDirect());
                        b.setHurt(getActionHurt("attack4_1"));
                        b.hitVO.addEffect = [{
                            type: AddEffectType.ROLE1_PASSIVE_FIRE,
                            frame: FrameRate.ANIMATE_FRAME_RATE * 5,
                            value: 1
                        }];
                    }
                    if (frameCount == 12)
                    {
                        b = new RegionBullet();
                        b.setCollideArea(-100, -114, 300 * bbdc.getDirect(), 130);
                        b.setDestroyInCount(6);
                        b.setOwner(this);
                        b.setAction("Role1Attack4_2");
                        b.setDirect(bbdc.getDirect());
                        b.setHurt(getActionHurt("attack4_2"));
                        b.hitVO.addEffect = [{
                            type: AddEffectType.ROLE1_PASSIVE_FIRE,
                            frame: FrameRate.ANIMATE_FRAME_RATE * 5,
                            value: 1
                        }];
                    }
                    break;
                case "attack5":
                    if (frameCount == 1)
                    {
                        b = new RegionBullet();
                        b.setCollideArea(0, -100, 100 * bbdc.getDirect(), 100);
                        b.setDestroyInCount(bbdc.frameLeft);
                        b.setOwner(this);
                        b.setAction("Role1Attack5");
                        b.setDirect(bbdc.getDirect());
                        b.setHurt(getActionHurt("attack5"));
                        b.hitVO.addEffect = [{
                            type: AddEffectType.ROLE1_PASSIVE_FIRE,
                            frame: FrameRate.ANIMATE_FRAME_RATE * 5,
                            value: 2
                        }];
                    }
                    break;
                case "skill1":
                    //升龙斩
                    if (frameCount == 5)
                    {
                        b = new RegionBullet();
                        b.setCollideArea(-58, -247.55, 315 * bbdc.getDirect(), 276);
                        b.setDestroyInCount(bbdc.frameLeft);
                        b.setOwner(this);
                        b.setAction("Role1Skill1");
                        b.setDirect(bbdc.getDirect());
                        b.setHurt(getActionHurt("skill1_1"));
                        b.hitVO.addEffect = [{
                            type: AddEffectType.ROLE1_PASSIVE_FIRE,
                            frame: FrameRate.ANIMATE_FRAME_RATE * 5,
                            value: 3
                        }];
                    }
                    break;
                case "skill1_2":
                    //升龙斩2段
                    setSteelBody(2)
                    if (frameCount == 7)
                    {
                        b = new RegionBullet();
                        b.setCollideArea(-25, -130, 242.5 * bbdc.getDirect(), 190.05);
                        b.setDestroyInCount(bbdc.frameLeft);
                        b.setOwner(this);
                        b.setAction("Role1Skill1_2");
                        b.setDirect(bbdc.getDirect());
                        b.setHurt(getActionHurt("skill1_2"));
                    }
                    break;
                case "skill2":
                    velocity.x = 35 * bbdc.getDirect();
                    //烈焰闪
                    if (frameCount == 3)
                    {
                        setInvincible(bbdc.frameLeft);
                        b = new RegionBullet();
                        b.setCollideArea(-120, -155, 250 * bbdc.getDirect(), 208);
                        b.setDestroyInCount(bbdc.frameLeft);
                        b.setOwner(this);
                        b.setAction("Role1Skill2");
                        b.setDirect(bbdc.getDirect());
                        b.setHurt(getActionHurt("skill2"));
                    }
                    break;
                case "skill3":
                    //连斩1段
                    if (frameCount == 5)
                    {
                        SoundManager.playSound("Role1_skill3_1");
                        b = new RegionBullet();
                        b.setCollideArea(-36, -97.8, 152 * bbdc.getDirect(), 107);
                        b.setDestroyInCount(5);
                        b.setOwner(this);
                        b.setAction("Role1Skill3_1");
                        b.setDirect(bbdc.getDirect());
                        b.setHurt(getActionHurt("skill3_1"));
                    }
                    if (frameCount == 12)
                    {
                        SoundManager.playSound("Role1_skill3_2");
                        moveTo(120 * bbdc.getDirect(), 0);
                        b = new RegionBullet();
                        b.setCollideArea(-90, -91.25, 300.05 * bbdc.getDirect(), 106.3);
                        b.setDestroyInCount(8);
                        b.setOwner(this);
                        b.setAction("Role1Skill3_2");
                        b.setDirect(bbdc.getDirect());
                        b.setHurt(getActionHurt("skill3_2"));
                    }
                    if (frameCount == 23)
                    {
                        SoundManager.playSound("Role1_skill3_3");
                        moveTo(120 * bbdc.getDirect(), 0);
                        b = new RegionBullet();
                        b.setCollideArea(-40, -187.5, 261.25 * bbdc.getDirect(), 201);
                        b.setDestroyInCount(5);
                        b.setOwner(this);
                        b.setAction("Role1Skill3_3");
                        b.setDirect(bbdc.getDirect());
                        b.setHurt(getActionHurt("skill3_3"));
                        b.hitVO.addEffect = [{
                            type: AddEffectType.ROLE1_PASSIVE_FIRE,
                            frame: FrameRate.ANIMATE_FRAME_RATE * 5,
                            value: 3
                        }];
                    }
                    break;
                case "skill3_2":
                    //连斩2段
                    setSteelBody(2);
                    if (frameCount == 11 && isInSky())
                    {
                        bbdc.gotoAndPlay(5);
                    }
                    if (frameCount == 6)
                    {
                        //空中连击
                        SoundManager.playSound("Role1_skill3_4");
                        b = new RegionBullet();
                        b.setCollideArea(-120, -140.8, 262.6 * bbdc.getDirect(), 230.6);
                        b.setDestroyInCount(5);
                        b.setOwner(this);
                        b.setAction("Role1Skill3_4");
                        b.setDirect(bbdc.getDirect());
                        b.setHurt(getActionHurt("skill3_4"));
                    }
                    if (frameCount == 14)
                    {
                        SoundManager.playSound("Role1_skill3_5");
                        setStatic();
                        gc.vController.shake(5);
                        b = new RegionBullet();
                        b.setCollideArea(-110, -262.8, 302.6 * bbdc.getDirect(), 262.6);
                        b.setDestroyInCount(5);
                        b.setOwner(this);
                        b.setAction("Role1Skill3_5");
                        b.setDirect(bbdc.getDirect());
                        b.setHurt(getActionHurt("skill3_5"));
                    }
                    break;
                case "skill4":
                    //身外身
                    if (frameCount == 4)
                    {
                        SoundManager.playSound("Role1_skill3_1");
                        setSteelBody(bbdc.frameLeft);
                        b = new RegionBullet();
                        b.setCollideArea(20, -102.9, 163 * bbdc.getDirect(), 105.45);
                        b.setDestroyInCount(8);
                        b.setOwner(this);
                        b.setAction("Role1Skill4_1");
                        b.setDirect(bbdc.getDirect());
                        b.setHurt(getActionHurt("skill4"));
                        createShadow();
                    }
                    if (frameCount == 16)
                    {
                        SoundManager.playSound("Role1_skill3_2");
                        b = new RegionBullet();
                        b.setCollideArea(-46, -162.5, 270 * bbdc.getDirect(), 173.8);
                        b.setDestroyInCount(6);
                        b.setOwner(this);
                        b.setAction("Role1Skill4_2");
                        b.setDirect(bbdc.getDirect());
                        b.setHurt(getActionHurt("skill4"));
                        createShadow();
                    }
                    if (frameCount == 23)
                    {
                        SoundManager.playSound("Role1_skill3_3");
                        b = new RegionBullet();
                        b.setCollideArea(9, -212.5, 197.55 * bbdc.getDirect(), 221.3);
                        b.setDestroyInCount(4);
                        b.setOwner(this);
                        b.setAction("Role1Skill4_3");
                        b.setDirect(bbdc.getDirect());
                        b.setHurt(getActionHurt("skill4"));
                        createShadow();
                    }
                    if (frameCount == 29)
                    {
                        SoundManager.playSound("Role1_skill3_4");
                        b = new RegionBullet();
                        b.setCollideArea(-100, -196.25, 306.3 * bbdc.getDirect(), 265.05);
                        b.setDestroyInCount(6);
                        b.setOwner(this);
                        b.setAction("Role1Skill4_4");
                        b.setDirect(bbdc.getDirect());
                        b.setHurt(getActionHurt("skill4"));
                    }
                    if (frameCount == 35 && isInSky())
                    {
                        bbdc.gotoAndPlay(28);
                    }
                    if (frameCount == 36)
                    {
                        setStatic();
                    }
                    if (frameCount == 38)
                    {
                        SoundManager.playSound("Role1_skill3_5");
                        b = new RegionBullet();
                        b.setCollideArea(40, -220, 281.3 * bbdc.getDirect(), 245.05);
                        b.setDestroyInCount(bbdc.frameLeft);
                        b.setOwner(this);
                        b.setAction("Role1Skill4_5");
                        b.setDirect(bbdc.getDirect());
                        b.setHurt(getActionHurt("skill4_2"));
                        createShadow();
                    }
                    break;
                case "skill6":
                    //火魔斩
                    if (frameCount == 1)
                    {
                        setInvincible(bbdc.frameLeft);
                        b = new RegionBullet();
                        b.setCollideArea(-237, -325.05, 474 * bbdc.getDirect(), 325.05);
                        b.setDestroyInCount(27);
                        b.setOwner(this);
                        b.setAction("Role1Skill6_1");
                        b.setDirect(bbdc.getDirect());
                        b.setHurt(getActionHurt("skill6_1"));
                    }
                    if (frameCount == 34)
                    {
                        SoundManager.playSound("Role1_skill6_2");
                        b = new RegionBullet();
                        b.setCollideArea(-109, -325.05, 218 * bbdc.getDirect(), 325.05);
                        b.setDestroyInCount(bbdc.frameLeft);
                        b.setOwner(this);
                        b.setAction("Role1Skill6_2");
                        b.setDirect(bbdc.getDirect());
                        b.setHurt(getActionHurt("skill6_2"));
                    }
                    break;
                case "skill7":
                    //定海神针
                    if (frameCount == 1)
                    {
                        setSteelBody(bbdc.frameLeft);
                    }
                    if (frameCount == 8)
                    {
                        b = new RegionBullet();
                        b.setCollideArea(-112, -351.05, 223 * bbdc.getDirect(), 351.05);
                        b.setDestroyInCount(bbdc.frameLeft);
                        b.setOwner(this);
                        b.setAction("Role1Skill7");
                        b.setDirect(bbdc.getDirect());
                        b.setHurt(getActionHurt("skill7"));
                    }
                    break;
                case "skill8":
                    //血魔咆哮
                    if (frameCount == 8)
                    {
                        b = new RegionBullet();
                        b.setCollideArea(-100, -360, 400 * bbdc.getDirect(), 360);
                        b.setDestroyInCount(23);
                        b.setOwner(this);
                        b.setAction("Role1Skill8_1");
                        b.setDirect(bbdc.getDirect());
                        b.setHurt(getActionHurt("skill8_1"));
                    }
                    if (frameCount == 32)
                    {
                        SoundManager.playSound("Role1_skill8_2");
                        b = new RegionBullet();
                        b.setCollideArea(-100, -360, 400 * bbdc.getDirect(), 360);
                        b.setDestroyInCount(15);
                        b.setOwner(this);
                        b.setAction("Role1Skill8_2");
                        b.setDirect(bbdc.getDirect());
                        b.setHurt(getActionHurt("skill8_2"));
                    }
            }
            if (b)
            {
                gc.gameScene.addChild(b);
                magicBulletArray.push(b);
            }
        }
        
        override protected function onActionOver(action:String):void
        {
            switch (action)
            {
                case "idle":
                case "attack1":
                case "attack2":
                case "attack3":
                case "attack4":
                case "attack5":
                default:
                    setAction("idle");
                    break;
                case "jump2":
                case "jump3":
                    setAction("jump3");
                    break;
                case "jump1":
                    setAction("jump1");
                    break;
                case "hurt":
                    setAction("hurt");
                    break;
            }
        }
        
        override public function hit(bul:BaseBullet,target:BaseObject,result:HitResultVO):void
        {
            super.hit(bul, target,result);
            var act:String = bul.hitVO.actionName;
            if(act == "Role1Skill6_2" || act == "Role1Skill7" || act == "Role1Skill8_2")
            {
                if(!target.curAddEffect.hasEffect(AddEffectType.ROLE1_PASSIVE_FIRE))
                {
                    return;
                }
                var eff:AddEffectVO =  target.curAddEffect.getEffectByType(AddEffectType.ROLE1_PASSIVE_FIRE);
                target.curAddEffect.removeEffectByType(AddEffectType.ROLE1_PASSIVE_FIRE);
                var bullet:FollowTargetBullet = new FollowTargetBullet("Role1BulletPassive");
                bullet.setIsDestroyWhenLastFrame();
                bullet.setOwner(this);
                bullet.setTarget(target);
                bullet.setClipOffset(-200,-220);
                bullet.setDisable();
                var vo:HitResultVO = new HitResultVO();
                vo.hurt = getAtk() * eff.value;
                vo.hitType = HitType.MAGIC;
                target.loseHp(vo);
                gc.gameScene.addChild(bullet);
                magicBulletArray.push(bullet);
            }
        }
        
        private function createShadow():BaseSummon
        {
            var shadow:Role1Shadow = new Role1Shadow();
            shadow.setAction(curAction);
            if (curAction == "skill4")
            {
                shadow.setLostGravity();
                shadow.getBBDC().gotoAndStop(bbdc.currentFrame);
            }
            shadow.setOwner(this);
            shadow.x = x;
            shadow.y = y;
            if (bbdc.getDirect() == 1)
            {
                shadow.getBBDC().turnRight();
            }
            else
            {
                shadow.getBBDC().turnLeft();
            }
            shadowArray.push(shadow);
            gc.gameScene.addChildAt(shadow, gc.gameScene.getChildIndex(this));
            gc.pWorld.getSummonArray().push(shadow);
            return shadow;
        }
        
        private function getPassiveMonsters(passiveNum:int = 3):Array
        {
            return gc.pWorld.getMonsterArray().filter(function (mon:BaseMonster, ...a):Boolean
            {
                return !mon.isDead() &&
                        mon.curAddEffect.hasEffect(AddEffectType.ROLE1_PASSIVE_FIRE) &&
                        mon.curAddEffect.getEffectByType(AddEffectType.ROLE1_PASSIVE_FIRE).value >= passiveNum;
            });
        }
        
        override public function renderAnimate():void
        {
            super.renderAnimate();
            var trash:Array = [];
            if (shadowArray.length > 0)
            {
                for each (var shadow:Role1Shadow in shadowArray)
                {
                    if (shadow.isReadyToDestroy)
                    {
                        trash.push(shadow);
                    }
                }
                ArrayUtil.removeElementFromAnother(trash, shadowArray);
            }
        }
        
        override public function stepKeyInput():void
        {
            super.stepKeyInput();
            if (keyInput.isAttack())
            {
                if (isRunning())
                {
                    normalAttack();
                }
                else
                {
                    normalAttack();
                }
            }
        }
        
        override protected function showSkill(index:int = 0):void
        {
            if (!getPlayer()) return;
            var skill_quip:SkillVO = getPlayer().getEquippedSkillByIndex(index);
            if (!skill_quip) return;
            var skill_std:SkillVO = gc.configManager.skillProxy.getSkillById(skill_quip.skillId);
            if (!skill_std.skillAction) return;
            var mpCost:int = skill_std.getMpCostByLevel(skill_quip.skillLevel);
            if (isAttacking() || isBeAttacking())
            {
                return;
            }
            if (getMp() < mpCost)
            {
                return;
            }
            getAttribute().reduceMp(mpCost);
            normalAttackNum = 0;
            setAction(skill_std.skillAction);
        }
        
        override public function normalAttack():void
        {
            var inter:int = _framer - timerDict.lastAttackTime;
            if (inter > 5 * FrameRate.ANIMATE_FRAME_RATE)
            {
                normalAttackNum = 0;
            }
            if (isInSky())
            {
                if (!isAttacking() && !isBeAttacking())
                {
                    if (inter < FrameRate.ANIMATE_FRAME_RATE)
                    {
                        return;
                    }
                    setAction("attack1");
                    normalAttackNum = 0;
                    SoundManager.playSound("Role1_hit1AndHit2");
                }
                return;
            }
            var needInter:int = 0;
            //needInter为前一个动作需要预留多少时间
            //case 2 为给动作1预留的时间
            //case 1 为给动作5预留的时间
            //由于从头开始的时候normalAttackNum为0，因此不会进入等待
            switch (normalAttackNum)
            {
                case 1:
                    needInter = 15;
                    break;
                case 2:
                    needInter = 13;
                    break;
                case 3:
                    needInter = 15;
                    break;
                case 4:
                    needInter = 20;
                    break;
                case 5:
                    needInter = 15;
            }
            if (inter < needInter)
            {
                return;
            }
            if (!isRunning() && (!isAttacking() || isNormalHit()))
            {
                if (++normalAttackNum > 5) normalAttackNum = 1;
                if (normalAttackNum == 1 || normalAttackNum == 2)
                {
                    SoundManager.playSound("Role1_hit1AndHit2");
                }
                else
                {
                    if (normalAttackNum == 3 || normalAttackNum == 4)
                    {
                        SoundManager.playSound("Role1_hit3AndHit4");
                    }
                    else
                    {
                        SoundManager.playSound("Role1_skill1_2");
                    }
                }
                setAction("attack" + normalAttackNum);
            }
            else
            {
                if (isRunning() && !isAttacking())
                {
                    if (getPlayer())
                    {
                        setAction("attack1");
                        SoundManager.playSound("Role1_hit1AndHit2");
                        keyInput.cancelRun();
                        normalAttackNum = 1;
                    }
                }
            }
            timerDict.lastAttackTime = _framer;
        }
        
        override public function refreshAppearance():void
        {
            var show:Object = getPlayer().getEquipAppearance();
            bbdc.changeAppearance("Role1Action",show);
            super.refreshAppearance();
        }
        
        override public function isNormalHit():Boolean
        {
            return curAction.indexOf("attack") != -1
        }
        
        override public function initAttribute():void
        {
            roleProperties.hpMax = 80 + 50 * (roleProperties.level - 1);
            roleProperties.mpMax = 50 + 20 * (roleProperties.level - 1);
            roleProperties.atk = 10 + 5 * (roleProperties.level - 1);
            roleProperties.def = 2 + 2 * (roleProperties.level - 1);
            super.initAttribute();
        }
        
        override public function getActionHurt(action:String):int
        {
            var hurt:Number = 0;
            var atk:int = getAtk();
            var getVO:Function = function (skillId:String):SkillVO
            {
                return getPlayer().getEquippedSkillBySkillId(skillId) || new SkillVO();
            }
            switch (action)
            {
                case "attack1":
                case "attack2":
                    hurt = 0.7;
                    break;
                case "attack3":
                    hurt = 0.6;
                    break;
                case "attack4_1":
                case "attack4_2":
                    hurt = 0.8;
                    break;
                case "attack5":
                    hurt = 1.2;
                    break;
                case "skill1_1":
                    hurt = getVO("slz").getSkillHurt();
                    break;
                case "skill1_2":
                    hurt = getVO("slz").getSkillHurt() * 2;
                    break;
                case "skill2":
                    hurt = getVO("lys").getSkillHurt();
                    break;
                case "skill3_1":
                case "skill3_2":
                case "skill3_3":
                case "skill3_4":
                    hurt = getVO("lz").getSkillHurt();
                    break;
                case "skill3_5":
                    hurt = getVO("lz").getSkillHurt() * 1.2;
                    break;
                case "skill4":
                    hurt = getVO("sws").getSkillHurt();
                    break;
                case "skill4_2":
                    hurt = getVO("sws").getSkillHurt() * 1.1;
                    break;
                case "skill6_1":
                    hurt = getVO("hmz").getSkillHurt();
                    break;
                case "skill6_2":
                    hurt = getVO("hmz").getSkillHurt() * 2;
                    break;
                case "skill7":
                    hurt = getVO("dhsz").getSkillHurt();
                    break;
                case "skill8_1":
                    hurt = getVO("xmpx").getSkillHurt();
                    break;
                case "skill8_2":
                    hurt = getVO("xmpx").getSkillHurt() * 2;
                    hurt *= 2 - getAttribute().getHpPercent() / 100;
                    break;
            }
            hurt *= atk;
            hurt *= isGXP ? 1.5 : 1;
            return hurt;
        }
        
        override protected function isCannotMoveWhenAttackOnFloor():Boolean
        {
            return curAction == "attack1" || curAction == "attack2" || curAction == "attack3" && jumpCount == 0 || curAction == "attack4" || curAction == "attack5";
        }
        
        override public function isAttacking():Boolean
        {
            return curAction.indexOf("attack") != -1 || curAction.indexOf("skill") != -1;
        }
        
        override protected function isCannotMoveWhenAttack():Boolean
        {
            const list:Array = [
                "skill1_2",
                "skill7",
                "skill6",
                "skill6_2",
                "skill8"
            ]
            return ArrayUtil.contains(list, curAction);
        }
        
        override public function isCanMoveWhenAttack():Boolean
        {
            const list:Array = [
                "skill1",
                "skill2",
                "skill4",
                "skill3_2",
                "skill3"
            ]
            return ArrayUtil.contains(list, curAction);
        }
        
        override public function destroy():void
        {
            super.destroy();
            for each(var shadow:Role1Shadow in shadowArray)
            {
                shadow.destroy();
            }
        }
    }
}